<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>BOA_RateCard_CHI_CHAR_NY</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.roundabout.js"></script>

<script>

  $("#slideshow > div:gt(0)").hide();

  setInterval(function() { 
    $('#slideshow > div:first')
      .fadeOut()
      .next()
      .fadeIn(1000)
      .delay(4000)
      .fadeOut(500)
      .end()
      .appendTo('#slideshow');
  },  5500);
      
    
  $(document).ready(function() {
    $('ul').roundabout({
        maxScale: 1,
        minScale: 0.3,
        minOpacity: 0.2,
        autoplay: true,
    }); 
    $('ul').roundabout("changeAutoplayDuration", 5500);
 });
</script>




<!-- Set Cookies-->
<!-- For the first time page loading or reloading, check the cookie first 
to see if it is empty or not. If it is not empty and not expired, 
retrieve the data in the cookie and send them to the rate card. -->
<script>
function getCookie(c_name) {
    //alert("getCookie test");
    var c_value = document.cookie;
    var c_start = c_value.indexOf(" " + c_name + "=");
    if (c_start == -1) {
      c_start = c_value.indexOf(c_name + "=");
    }
    if (c_start == -1) {
      c_value = null;
    }
    else {
      c_start = c_value.indexOf("=", c_start) + 1;
      var c_end = c_value.indexOf(";", c_start);
      if (c_end == -1) {
            c_end = c_value.length;
        }
      c_value = unescape(c_value.substring(c_start,c_end));
    }
    return c_value;
}

function setCookie(c_name,value,exdays) {
    //alert("setCookie test");
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value);
    document.cookie = c_name + "=" + c_value;
    document.cookie = "expires=" + exdate.toUTCString();
}

function checkCookie(c_name) {
    //alert("checkCookie Test");//test
    var value = getCookie(c_name);
    //alert(document.cookie);//test
    if (value==null || value=="") {
        setCookie(c_name, "", 1);
        //alert("set up!");//test
      }
    if (value!=null && value!="") {
        loadCookie();
        //hide Backup image
        $('#imageBackup').hide();
        $("#mainC").show();
      }
    else {
        //alert("test if the cookie is empty:" + document.cookie);//test
        setCookieFromJSON();
        var return_value = checkGetJSONStatus();
        alert(return_value);//test
        if(return_value) { // getJSON success
            alert("getjson succ");//test
            loadCookie();
        }
        else { //getJSON fail, show defalut image
            alert("getjson fail");//test
        }
    }
}


function eraseCookie(c_name) {
    setCookie(c_name, "", -1);//to set the cookie expired to disable it
}


// function eraseAllCookie() { //erase all values in the cookie
//     alert("Try to erase all cookies and set expire to past.");
//     //alert("getCookie test");

//     var c_value = document.cookie; //get the cookie string
//     var cookie_pointer_back = -1; //initialize the pointer 1 to the start of the string
//     var cookie_pointer_front = c_value.indexOf("=", -1) //find the c_name from the start of the string
//     var name_length = cookie_pointer_front - 1;
//     var current_name = c_value.substr(cookie_pointer_back, name_length);
//     alert("subtring" + current_name);//test

//     document.cookie = current_name + "=" + ""; //erase the value of the current_name
//     cookie_pointer_back = cookie_pointer_front + 1;//move the pointer to the next cookie name

//     cookie_pointer_front = c_value.indexOf("=", cookie_pointer_back); //to find the next name
//     name_length = cookie_pointer_front - cookie_pointer_back;
//     current_name = c_value.substr(cookie_pointer_back, name_length);
//     document.cookie = current_name + "=" + "";
//     cookie_pointer_back = cookie_pointer_front + 1;
// }
</script>




<!-- Set the cookie-->
<script>
function setCookieFromJSON () {
    alert("here is setCookieFromJSON");//test    
    var data_str = null;
	var url = "https://test2.bridgetree.com/rateboard/ratefeed/?state=NY&callback=?";
    //to get the local machine time
    var newDate = new Date();
    var date = newDate.getDate();
    var month = newDate.getMonth() + 1; // Note: 0 = January, 1 = February etc.
    var year = newDate.getFullYear().toString().substr(2,2);
    if(date < 10) {
        var date_str = '0' + date.toString();
    }
    else {
        var date_str = date.toString();
    }

    document.getElementById("todayDate").innerHTML = date_str;
    document.getElementById("todayMonth").innerHTML = month.toString();
    document.getElementById("todayYear").innerHTML = year;
    var fullDate = month.toString() + '/' + date_str + '/' + year;



    //to get data from dynamically URL
    $.getJSON(url, function(result){
        data_str = JSON.stringify(result);
		
        $.each(result.MortgageRates, function() {
			
            //to get the 30YR FIXED JUMBO data and exchange the present content of inputs of card 1
            if(this.MortName == "30YR FIXED CONFORMING" && this.MortProductGroup == "10") {
                document.cookie = "30YR_MortApr=" + this.MortApr;
                document.cookie = "30YR_MortRate=" + this.MortRate;
                document.cookie = "30YR_MortMonthlyPaymentPer1000=" + this.MortRate;
                if(this.MortPoints < 1) {
                  document.cookie = "30YR_MortPoints=0" + this.MortPoints;
                }
                else {
                  document.cookie = "30YR_MortPoints=" + this.MortPoints;
                }
                document.cookie = "30YR_Date=" + fullDate;
            }
            //to get the 15YR FIXED CONFORMING data and exchange the present content of inputs of card 2
            else if(this.MortName == "15YR FIXED CONFORMING" && this.MortProductGroup == "40") {
                document.cookie = "15YR_MortApr=" + this.MortApr;
                document.cookie = "15YR_MortRate=" + this.MortRate;
                document.cookie = "15YR_MortMonthlyPaymentPer1000=" + this.MortMonthlyPaymentPer1000;
                if(this.MortPoints < 1) {
                    document.cookie = "15YR_MortPoints=0" + this.MortPoints;
                }
                else {
                    document.cookie = "15YR_MortPoints=" + this.MortPoints;
                }
                document.cookie = "15YR_Date=" + fullDate;
            }
        })  //-----MortgageRates------
        

        //to get the HomeEquityRates data and exchange the present content of inputs of card 3
        $.each(result.HomeEquityRates, function() {
          if(this.HeRateMinLoanAmount == "50000"){
            document.cookie = "HE_HeRate=" + this.HeRate;
            document.cookie = "HE_HeRateMinLoanAmount=" + this.HeRateMinLoanAmount;
            document.cookie = "HE_MonthlyPaymentPer1000=" + this.MonthlyPaymentPer1000;
            document.cookie = "HE_IndexValue=" + this.IndexValue;
            document.cookie = "HE_Date=" + fullDate;
          }
        })//------HomeEquityRates------

        setCookie("HE_Date", fullDate, 1); // to set the expire time to 1 day

    }).fail(function() {
        alert("GET JSON FAIL, SHOW DEFAULT IMAGE!");//test
        eraseCookie("30YR_MortApr");
    });//------getJSON--------
}
</script>

<script>
    function checkGetJSONStatus() {
        //to check if the getJSON() succeed
        alert(document.cookie);//test
        var return_value = null; // 0 indicates failure, 1 indecates success
        var value = getCookie("30YR_MortApr");
        alert("check if 30YR mortapr is null: " + value);//test
        if (value!=null && value!="") {
            return_value = 1;//success
        }
        else {
            return_value = 0;//failure
        }
        return return_value;
    }
</script>


<!-- load the cookie data as the card inputs-->
<script>
    function loadCookie() {
        document.getElementById("30YR_MortApr").innerHTML = getCookie("30YR_MortApr");
        document.getElementById("30YR_MortRate").innerHTML = getCookie("30YR_MortRate");
        document.getElementById("30YR_MortMonthlyPaymentPer1000").innerHTML = getCookie("30YR_MortMonthlyPaymentPer1000");
        document.getElementById("30YR_MortPoints").innerHTML = getCookie("30YR_MortPoints");
        document.getElementById("30YR_Date").innerHTML = getCookie("30YR_Date");

        document.getElementById("15YR_MortApr").innerHTML = getCookie("15YR_MortApr");
        document.getElementById("15YR_MortRate").innerHTML = getCookie("15YR_MortRate");
        document.getElementById("15YR_MortMonthlyPaymentPer1000").innerHTML = getCookie("15YR_MortMonthlyPaymentPer1000");
        document.getElementById("15YR_MortPoints").innerHTML = getCookie("15YR_MortPoints");
        document.getElementById("15YR_Date").innerHTML = getCookie("15YR_Date");

        document.getElementById("HE_HeRate").innerHTML = getCookie("HeRate");
        document.getElementById("HE_HeRateMinLoanAmount").innerHTML = getCookie("HE_HeRateMinLoanAmount");
        document.getElementById("HE_MonthlyPaymentPer1000").innerHTML = getCookie("MonthlyPaymentPer1000");
        document.getElementById("HE_IndexValue").innerHTML = getCookie("IndexValue");
        document.getElementById("HE_Date").innerHTML = getCookie("HE_Date");
    }
</script>


<script>
    $(document).ready(function() {
        var present_date = new Date();
        var present_hour = present_date.getHours();
        if(present_hour == 9 || present_hour == 19) {
            alert("It's time to update!");//test
            setCookieFromJSON();
            loadCookie();
        }
        else {
            alert("Not update time now. Check the cookie");//test
            checkCookie("30YR_MortApr");
        }
    });
</script>
</head>

<!--body onload="checkCookie('30YR_MortApr')"-->
<body>

<div id="imageBackup"><img src="images/Digital_rateboard_default_final.jpg"></div>
<div id="mainC" class="mainContainer" style="display:none">
    <div id="slideshow">
        <div>
          <div class="pageTitleContainer">
            <div class="pageTitle">
                <p>Today's Purchase Rate</p>
            </div><!--.pageTitle-->
          </div><!--.pageTitleContainer--> 
          
          <div class="headlineContainer">
            <div class="headline">
                <p class="biggerText">Looking to<br>buy a home?</p>
            </div><!--.headline-->
          </div><!-- .headlineContainer -->
        </div>
        
        <div>
          <div class="pageTitleContainer">
            <div class="pageTitle">
                <p>Today's Refinance Rates</p>
            </div><!--.pageTitle-->
          </div><!--.pageTitleContainer-->
                    
          <div class="headlineContainer">
            <div class="headline">
                <p>Want a lower<br>monthly payment?</p>
            </div><!--.headline-->
          </div><!-- .headlineContainer -->
        </div>
        
        <div>
          <div class="pageTitleContainer">
              <div class="pageTitle">
                  <p>Today's Home Equity Rates</p>
              </div><!--.pageTitle-->
            </div><!--.pageTitleContainer-->
                     
            <div class="headlineContainer">
            <div class="headline">
                <p>Need flexible<br>access to funds?</p>
            </div><!--.headline-->
          </div><!-- .headlineContainer -->
        </div>
        
        <div>
            <div class="pageTitleContainer">
              <div class="pageTitle">
                  <p>Mortgage Specialist</p>
              </div><!--.pageTitle-->
            </div><!--.pageTitleContainer-->
                     
            <div class="headlineContainer">
            <div class="headline">
                <p>Get your<br>personalized rate<br>quote today</p>
            </div><!--.headline-->
          </div><!-- .headlineContainer -->
        </div>        
    </div><!--#slideshow-->
    

    
        
    <div id="carousel">
        <ul>
            <li class="card1">
                <div id="input1">
                    <p id="30YR_MortRate">2.344</p>
                </div><!--#input-->
                <div id="input2">
                    <p id="30YR_MortApr">2.234</p>
                </div><!--#input-->
                <div id="input3">
                    <p id="30YR_MortPoints">3.23</p>
                </div><!--#input-->
                <div id="input4">
                    <p id="30YR_MortMonthlyPaymentPer1000">4.23</p>
                </div><!--#input-->
                <div id="input5">
                    <p id="30YR_Date">mm/dd/yy</p>
                </div><!--#input-->
                <img src="Asset/card_fixedRateMort_30yr.png">
                <img src="Asset/card_reflection.png">
                <div id="whiteBox"></div>
            </li><!--card-->
        
        
        
            <li class="card2">
                <div id="input1">
                    <p id="15YR_MortRate">2.344</p>
                </div><!--#input-->
                <div id="input2">
                    <p id="15YR_MortApr">2.234</p>
                </div><!--#input-->
                <div id="input3">
                    <p id="15YR_MortPoints">3.23</p>
                </div><!--#input-->
                <div id="input4">
                    <p id="15YR_MortMonthlyPaymentPer1000">4.23</p>
                </div><!--#input-->
                <div id="input5">
                    <p id="15YR_Date">mm/dd/yy</p>
                </div><!--#input-->
                <img src="Asset/card_fixedRateMort_15yr.png">
                <img src="Asset/card_reflection.png">
                <div id="whiteBox"></div>
            </li><!--card-->
        
            <li class="card3">
                <div id="input1">
                    <p id="HE_HeRate">2.44</p>
                </div><!--#input-->
                <div id="input2">
                    <p id="HE_HeRateMinLoanAmount">123.456</p>
                </div><!--#input-->
                <div id="input3">
                    <p id="HE_MonthlyPaymentPer1000">3.23</p>
                </div><!--#input-->
                <div id="input4">
                    <p id="HE_Date">mm/dd/yy</p>
                </div><!--#input-->
                <img src="Asset/card_lineOfCredit.png" />
                <img src="Asset/card_reflection.png">
                <div id="whiteBox"></div>
            </li><!--card-->
        
            <li class="card4">
                <img src="Asset/card_askHow.png"> 
                <img src="Asset/card_reflection.png">           
                <div id="whiteBox"></div>
            </li><!--card-->
        
         </ul>
 
    </div><!--#carousel-->

    <div class='legal'>
      <p>Fixed 30 Year: Rate and APR are based on $200,000 loan, 20% down payment and a borrower with excellent credit. For details, please see a Bank of America associate or log onto www.bankofamerica.com. Actual rate and APR will vary, based on factors such as points, loan amount, loan-to-value, borrower’s credit, property type, and occupancy. Other mortgage products are also available to meet your needs.</br>Fixed 15 Year Refinance: Rate and APR are based on $200,000, loan, 80% loan-to-value, and a borrower with excellent credit. For details, please see a Bank of America associate or log onto www.bankofamerica.com. Actual rate and APR will vary, based on factors such as points, loan amount, loan-to-value, borrower’s credit, property type, and occupancy. Other mortgage products are also available to meet your needs. Refinancing may increase the total number of monthly payments and/or the total amount paid when compared to your current situation.<br>HELOC: Sample variable Annual Percentage Rate (APR) is for illustrative purposes only and assumes a new home equity line of credit in second lien position, with a combined loan-to-value (CLTV) ratio of up to 70% on a 1- to 4-unit owner occupied primary residence, and a borrower with excellent credit. Minimum line amount is $25,000. The term of the loan is 25 years: 10-year draw period, 15-year repayment period. APR is based on The Wall Street Journal Prime Rate (<span id="HE_IndexValue">X.XX</span>% on <span id="todayMonth">XX</span>/<span id="todayDate">XX</span>/<span id="todayYear">XX</span>) plus a margin and will vary with the Prime Rate, but will not exceed 24%. Sample APR includes a 0.25% discount for maintaining automatic payment from a Bank of America account, and a 0.25% discount for drawing and maintaining an initial minimum balance of $25,000 for at least the first 3 full billing cycles. An additional discount is available for maintaining an eligible relationship status with Bank of America. Margin, rate and payment amounts may vary based on your property value, line amount and other factors. Property insurance is always required and flood insurance is required where necessary. To obtain a home equity line of credit from Bank of America, a security interest will be taken on borrower’s 1- to 4-unit owner-occupied primary residence or second home as collateral and the line of credit must be in first or second lien position. Mobile homes, manufactured homes, cooperatives, lots or homes undergoing construction and commercial properties are not eligible collateral. Primary borrower must be a title holder on collateral. Bank of America pays all closing costs (except in South Carolina where borrower pays attorney fees in excess of $300). The combined amount of all third-party fees, including any taxes owed to state and/or local government units, generally totals between $836.10 and $7,324.60 ($1,374.60 and $11,790.60 in New York). If you terminate your account within 36 months of opening it, you will be required to pay an early closure fee of $450 plus any mortgage and government taxes and any closing agent or attorney fees Bank of America paid on your behalf. Additional Information for Texas: Bank pays all closing costs on homestead property in Texas subject to Section 50(a)(6) of the Texas Constitution. Bank of America cannot use a customer’s home equity funds to pay (in part or in full) Bank of America non-homestead debt at closing. Early Closure Fee does not apply, and the minimum advance amount on the line of credit is $4,000. The maximum CLTV is 80% and the maximum LTV for the home equity line is 50%.<br>Bank of America and the Bank of America Logo are registered trademarks of Bank of America Corporation. Bank of America, N.A., Member FDIC.     Equal Housing Lender © 2013 Bank of America Corporation. ARUJBE94</p>
    </div><!--.legal-->

</div><!--.mainContainer-->


</body>
</html>
